package com.financing.platform.dao.impl;

import java.sql.SQLException;
import java.util.Collections;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.financing.platform.dao.IProjectCommentsDao;
import com.financing.platform.dto.ProjectCommentsDTO;
import com.financing.platform.util.SqlName;
import com.financing.platform.vo.ProjectCommentsVO;

@Repository("projectCommentsDaoImpl")
public class ProjectCommentsDaoImpl extends BaseDaoImpl implements
		IProjectCommentsDao {

	public Integer addProjectComments(ProjectCommentsDTO projectCommentsDTO) {
		try {
			this.sqlMapClient.insert(SqlName.insertProjectComments, projectCommentsDTO);
		} catch (SQLException e) {
			log.error("Add project comments error !", e);
			return 0;
		}
		return 1;
	}

	@SuppressWarnings("unchecked")
	public List<ProjectCommentsVO> queryProjectComments(
			ProjectCommentsDTO projectCommentsDTO) {
		try {
			return (List<ProjectCommentsVO>) this.sqlMapClient.queryForList(SqlName.searchProjectCommentsByPid, projectCommentsDTO);
		} catch (SQLException e) {
			log.error("query project comments error :",e);
			return Collections.emptyList();
		}
	}

	public int updateProjectComment(ProjectCommentsDTO projectCommentsDTO)
			throws SQLException {
		return this.sqlMapClient.update(SqlName.updateProjectComment, projectCommentsDTO);
	}

}
